@use 'sass:map';
@use 'sass:meta';
@use './utilities' as utils;

$unit: 4px;

$spacing-data: (
  extra-tight: utils.rem($unit),
  tight: utils.rem($unit * 2),
  base: utils.rem($unit * 4),
  loose: utils.rem($unit * 5),
  extra-loose: utils.rem($unit * 8)
);

/// Returns the spacing value for a given variant.
///
/// @param {String} $variant - The key for the given variant.
/// @return {Number} The spacing for the variant.

@function spacing($variant: base) {
  $fetched-value: map.get($spacing-data, $variant);

  @if meta.type-of($fetched-value) == number {
    @return $fetched-value;
  } @else {
    @error 'Spacing variant `#{$variant}` not found. Available variants: #{available-names($spacing-data)}';
  }
}
